package red.mlz.gameservice.mapper.tag;

import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import red.mlz.common.entity.tag.Tag;

@Mapper
public interface TagMapper {

    // 根据ID查询操作
    @Select("select * from tag WHERE id =  #{tagId} AND is_deleted=0")
    Tag getById(Long tagId);

    // 根据ID提取操作
    @Select("select * from tag WHERE id =  #{tagId}")
    Tag extractById(Long tagId);

    // 插入操作
    Integer insert(Tag tag);

    // 更新操作
    Integer update(Tag tag);

    // 删除操作
    @Update("update tag set update_time = #{updateTime} , is_deleted = 1 WHERE tag_id = #{tagId}")
    Integer delete(@Param("updateTime") Integer updateTime, @Param("tagId")  Long tagId);

    @Select("select * from tag WHERE  name = #{tagName} AND is_deleted = 0")
    Tag findByName(String tagName);
}
